<%@page import="java.text.SimpleDateFormat"%>
<%@page import="Entity.*" import="Dao.*"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>实验安排</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha512-SfTiTlX6kk+qitfevl/7LibUOeJWlt9rbyDn92a1DqWOw9vWG2MFoays0sgObmWazO5BQPiFucnnEAjpAB+/Sw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
 	<link rel="shortcut icon" type="image/x-icon" href="logo.jpg" />
 	<style type="text/css">
 	a{text-decoration: none;color: black;}
 	a:hover{color: black;}
 	body {
	background-image: linear-gradient(to top, #e6e9f0 0%, #eef1f5 100%);
}
 	</style>
  </head>
  
  <body>
  
  	<% 
  	Date date;
  	if(request.getAttribute("date")!=null){
  		date=(Date)request.getAttribute("date");
  	}
  	else{
  	date=new Date();
  	}
  	if(request.getAttribute("r")==null){
  		request.getRequestDispatcher("queryCourses").forward(request,response);
  	}
  	 ArrayList<Boolean> r = (ArrayList<Boolean>)request.getAttribute("r");
	ArrayList<Course> ri = (ArrayList<Course>)request.getAttribute("ri");
	ArrayList<String> rin = (ArrayList<String>)request.getAttribute("rin");
	if(session.getAttribute("user")==null){
  	 	 request.getRequestDispatcher("login.jsp").forward(request,response);
  	 }
  	 User user =(User) session.getAttribute("user");
  	  String id=user.getUid(); 
  	 
  		 int utype =user.getUtype();
  	 String str[]={"有课","有课","有课","有课","有课"} ;
  	 int rooms=5; 
  	 String room[]={" ","第一大节","第二大节","第三大节","第四大节","第五大节"};
  	 
  	 java.util.Date date1=new java.util.Date();    
	  //设置好SimpleDateFormat的格式
	  SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
	  //获取当前时间，此时时间的格式为String
	  String source = df.format(date1);
	  //将String类型转换成Date形式
	  java.util.Date dd = df.parse(source);
	    System.out.print(source);
  	 %>
   
    <!-- 顶部-->
    	<div style="border: 1px;display: block;">
    			<image  src="image/title.png" style="width: 600px;">
    			<a href="personInfor.jsp" class="btn dropdown-toggle"  style="float: right;margin:auto 40px;">
    			<i class="fa fa-user-circle fa-2x"></i>
    			个人信息
		   		 </a>
    	</div>
    	<!-- 导航-->
   		<div style="float: left;width: 10%;height:90%; bottom:0;display: block;border-radius: 10px;
   		background-image: linear-gradient(to top, #accbee 0%, #e7f0fd 100%);">
   		<%
   			if(utype==1)
   			{
   		%>
   			<ul class="nav nav-pills nav-stacked">
			  <li><a href="RoomServlet"><img src="image/m_1.png" width="25px" style="margin-right: 5px;">机房信息</a></li>
			  <li><a href="SearchServlet?cpage=1">用户信息</a></li>
				  <li class="active">
					<a type="button" class="btn " data-toggle="collapse" 
					    data-target="#demo" >
					     实验安排
					</a>    
					<div id="demo" class="collapse"  style="text-align: center;
						background-image: linear-gradient(to top, #accbee 0%, #e7f0fd 100%);">
					  <a class="btn " href="class_total.jsp" style="color: white;
					  background-image: linear-gradient(to top, #6a85b6 0%, #bac8e0 100%);">课程日历</a>
					 <a class="btn " href="searchCourseServlet?page=1" style="color: white;">查看课程</a>
					</div>
				  <li><a href="EventServlet?page=1">考试/竞赛</a></li>
				  <li><a href="sendmessage.jsp">发件箱</a></li>
			</ul>
			<script type="text/javascript">
				 $(".collapse").collapse('show') 
			</script>
			
						
			<% 
   			}else if(utype==2)
   			{
   			%>
   			<ul class="nav nav-pills nav-stacked">
			  <li  class="active"><a href="class_total.jsp">创建课程</a></li>
			  <li><a href="Self_boocked?page_n=1">查看课程</a></li>
			  <li><a href="Notice1Servlet">收件箱</a></li>
			</ul>
			<%
   			}
   		 %>
   		
   			
   		</div>
    	<!-- 主体-->
    	
	    <div style="padding: 10px 0 5px 40px;width: 85%;float: left;">
	  		<div style="padding: 10px 0 15px 40px;">
	  			<form action="queryCourses" method="get" id="dateForm" name="dateForm" >
	  			<p class="lead"> 日期：
	  			<input type="date" id="date" name="date" onchange="upperCase();">
	  			</p>
	  			</form>
	    	</div>
	    	
	    	
	  		<div class=".table-responsive" style="">
	    	<table  frame="void" class="table" rules="none" style="text-align: center;margin: auto;line-height: 50px;margin-tp:5%;">
		    	<thead>
		    	<tr  class="info">
		    	<td>机房号</td>
		    	<td>1001</td>
		    	<td>1002</td>
		    	<td>1003</td>
		    	<td>1004</td>
		    	<td>1005</td>
		    	</tr>
		    	</thead>
		    	<tbody>
		    	
		    	<% 
		    	for(int i=1;i<6;i++){
		    	%>
		    	<tr  style="height: 70px;margin:auto;" >
		    		<td style="line-height: 70px;" class="info"><%=room[i] %></td>
    				<td >
    					<%
    						if(!r.get(i*5+1).booleanValue()){
    					%>
    						<a onclick="onclick1(<%=1001%>,<%= i%>)">空闲</a>
    					<%
    						}
    						else{
    					%>
    						已被占用<br>
    						课题：<%=ri.get(i*5+1).getCourse_Name() %><br>
    						教师：<%=rin.get(i*5+1)%>
    					<%		
    						}
    					 %>
    				
    				</td>
    				<td >
    				<%
    						if(!r.get(i*5+2).booleanValue()){
    					%>
    						<a onclick="onclick1(<%=1002%>,<%= i%>)">空闲</a>
    					<%
    						}
    						else{
    					%>
    						已被占用<br>
    						课题：<%=ri.get(i*5+2).getCourse_Name() %><br>
    						教师：<%=rin.get(i*5+2) %>
    					<%		
    						}
    					 %>
    				</td>
    				<td>
    				<%
    						if(!r.get(i*5+3).booleanValue()){
    					%>
    						<a onclick="onclick1(<%=1003%>,<%= i%>)">空闲</a>
    					<%
    						}
    						else{
    					%>
    						已被占用<br>
    						课题：<%=ri.get(i*5+3).getCourse_Name() %><br>
    						教师：<%=rin.get(i*5+3) %>
    					<%		
    						}
    					 %>
    				</td>
    				<td>
    				<%
    						if(!r.get(i*5+4).booleanValue()){
    					%>
    						<a onclick="onclick1(<%=1004%>,<%= i%>)">空闲</a>
    					<%
    						}
    						else{
    					%>
    						已被占用<br>
    						课题：<%=ri.get(i*5+4).getCourse_Name() %><br>
    						教师：<%=rin.get(i*5+4) %>
    					<%		
    						}
    					 %>
    				</td>
    				<td >
    				<%
    						if(!r.get(i*5+5).booleanValue()){
    					%>
    						<a onclick="onclick1(<%=1005%>,<%= i%>)">空闲</a>
    					<%
    						}
    						else{
    					%>
    						已被占用<br>
    						课题：<%=ri.get(i*5+5).getCourse_Name() %><br>
    						教师：<%=rin.get(i*5+5) %>
    					<%		
    						}
    					 %>
    				</td>
	    		</tr>
	    		<% 
	    		}
	    		%>
	    		<%
	    			session.setAttribute("date_c", date);
	    		 %>
		    	</tbody>
	    	</table>
	    	</div>
	    </div>
    </div>
    
    
    
    
    <div id="add_course" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    </div>
    <script type="text/javascript">
            var now = new Date();
        //格式化日，如果小于9，前面补0
        var day = ("0" + now.getDate()).slice(-2);
        //格式化月，如果小于9，前面补0
        var month = ("0" + (now.getMonth() + 1)).slice(-2);
        //拼装完整日期格式
        var today = now.getFullYear()+"-"+(month)+"-"+(day) ;
        document.getElementById("date").value=(today);
        //or  $("#date").val(today);
        </script>
       <script type="text/javascript">
		function upperCase()
		{
			document.getElementById("dateForm").submit();
		}
		</script> 
        <script type="text/javascript">
         var date_c =document.getElementById("date");
         function onclick1(x,y){
         	
         	location.href="pop_create.jsp?roomid="+x+"&orderr="+y;
         }	
        </script>
  </body>
</html>
